import api from '@/common/request/index.js'
let imgUrl = 'https://mystore-1304299581.cos.ap-guangzhou.myqcloud.com/static/image/'
import tools from '@/common/utils/tools.js'
const state = {
	notice_detail: {},
	category_a: [{
			cate_name: '默认',
			selected: false
		}, {
			cate_name: '好评数',
			selected: false
		}, {
			cate_name: '兑换量',
			selected: false
		},
		{
			cate_name: '距离远近',
			selected: false
		}
	],
	category: [],
	seller_list: [], // 商铺列表
	//详情
	sellerInfo: {},
	notice_list: [],
	comments: [],
	feedback: [], // 商家意见反馈
	gift:[]   ,// 猜你喜欢
	shopId: [],
	notice: [],  // 商家公告
	getShopId: 0, // 请求id
}

const mutations = {
	//商家入驻
	set_addSeller(state,payload) {
		state.seller_list = state.seller_list.concat(payload)
	},
	//获取商家详情
	set_sellerInfo(state,payload) {
		state.sellerInfo = payload;
	},
	set_gift(state,payload) {
		state.gift = payload
	},
	set_comment(state,payload) {
		state.comments = payload
	},
	set_feedback(state,payload) {
		state.feedback = payload
	},
	set_category(state, payload) {
		state.category = payload;
	}
}
const actions = {
	get_addSeller({commit},payload) {
		commit('set_addSeller',payload)
	},
	
	get_sellerInfo( {commit},payload ) {
		commit('set_sellerInfo',payload)
	},
	get_gift( {commit},payload ) {
		commit('set_gift',payload)
	},
	
	get_comment({commit}, payload) {
		commit('set_comment',payload)
	},
	get_feedback({commit}, payload) {
		commit('set_feedback',payload)
	},
	get_category({commit}, payload) {
		commit('set_category',payload)
	},
	// vuex api请求 商家公告
	get_shopCategoryS({commit, state}, payload) {
	    state.category = payload;
	},
	get_shopId({commit, state}, payload) {
	    state.shopId = payload;
	},
	get_getShopId({commit, state}, payload) {
	    state.getShopId = payload;
	},
	get_notice({commit, state}, payload) {
	    return new Promise((resolve, reject) => {
	        api('notice', payload).then(res => {
	            state.notice = res.data
	        })
	    })
	},
}



export default {
	namespaced: true,
	state,
	mutations,
	actions
}
